home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PORTABLE.ZIP / PAIRCONT.C < prev    next >
Text File  |  1992-11-21  |  2KB  |  53 lines

  1. #define        CURSES_LIBRARY  1
  2. #include <curses.h>
  3. #undef pair_content
  4.  
  5. #ifndef        NDEBUG
  6. char *rcsid_paircont = "$Header: c:/curses/portable/RCS/paircont.c%v 2.0 1992/11/15 03:29:07 MH Rel $";
  7. #endif
  8.  
  9.  
  10.  
  11.  
  12. /*man-start*********************************************************************
  13.  
  14.   pair_content()       - Obtain color-pair information.
  15.  
  16.   PDCurses Description:
  17.  
  18.        This routine is used to determine what the colors of a given color-pair
  19.        consist of.
  20.  
  21.        The routine uses three arguments: the colorpair number which
  22.        must be a value between 1 and COLOR_PAIRS-1 and the adresses of
  23.        two shorts for storing the obtained color components of foreground
  24.        and background. The function will store the current values at these
  25.        addresses passed. The values will be between 0 and COLORS-1.
  26.  
  27.   PDCurses Return Value:
  28.        This function returns OK on success and ERR on error.
  29.  
  30.   PDCurses Errors:
  31.        It is an error to call this function with a colorpair outside of the
  32.        range specified above.
  33.  
  34.   Portability:
  35.        PDCurses        int pair_content( int colorpair, short *foreground, short *background);
  36.        SYS V Curses    int pair_content( int colorpair, short *foreground, short *background);
  37.  
  38. **man-end**********************************************************************/
  39.  
  40.  
  41. int pair_content(int colorpair,short *foreground,short *background)
  42. {
  43.  extern int COLOR_PAIRS;
  44.  extern unsigned char atrtab[MAX_ATRTAB];
  45.  
  46.  if (colorpair >= COLOR_PAIRS || colorpair < 1)
  47.     return(ERR);
  48.  
  49.  *foreground = (short)(atrtab[colorpair] & 0x0F);
  50.  *background = (short)((atrtab[colorpair] & 0xF0)>>4);
  51.  return(OK);
  52. }
  53.